unit BuscarPedido;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, Mask, DmVariaveis;

type
  TFrmBuscarPedido = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Bevel1: TBevel;
    EdtDocumento: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    EdtData: TMaskEdit;
    Label2: TLabel;
    Cb_Buscar: TComboBox;
    Label3: TLabel;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure Cb_BuscarChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
    MrBuscarPedido : Integer;
  public
    { Public declarations }
  end;

var
  FrmBuscarPedido: TFrmBuscarPedido;

implementation

{$R *.dfm}

procedure TFrmBuscarPedido.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then begin
    key :=#0;
    perform(WM_NextDLGCtl,0,0);
  end;
end;

procedure TFrmBuscarPedido.Cb_BuscarChange(Sender: TObject);
begin
  if Cb_Buscar.ItemIndex = 0 then begin
    Label2.Visible  := false;
    EdtData.Visible := false;
  end
  else begin
    Label2.Visible  := true;
    EdtData.Visible := true;
  end;
end;

procedure TFrmBuscarPedido.FormShow(Sender: TObject);
begin
  Cb_BuscarChange(Cb_Buscar);
end;

procedure TFrmBuscarPedido.BitBtn1Click(Sender: TObject);
begin
  if (not (Pc_BusPed_[1] in ['3','4','5','6','7'])) then begin //Busca de Outros Sistemas
    if Cb_Buscar.ItemIndex = 0 then
      PC_BusPed_ := '1'
    else
      PC_BusPed_ := '2';
  end;
  MrBuscarPedido := mrOK;
  FrmBuscarPedido.Close;
end;

procedure TFrmBuscarPedido.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  ModalResult := MrBuscarPedido;
  Action := cafree;
end;

procedure TFrmBuscarPedido.FormCreate(Sender: TObject);
begin
  MrBuscarPedido := mrNone;
end;

procedure TFrmBuscarPedido.BitBtn2Click(Sender: TObject);
begin
  MrBuscarPedido := mrCancel;
end;

end.
